package com;

import java.nio.ByteBuffer;
import java.nio.channels.AsynchronousSocketChannel;
import java.nio.channels.CompletionHandler;

public class ReadHandler implements CompletionHandler<Integer, ByteBuffer> {
    public ReadHandler(AsynchronousSocketChannel asc) {

    }

    // 读取到消息后的处理
    @Override  
    public void completed(Integer result, ByteBuffer attachment) {  
        //attachment 就是数据，调用 flip 操作，其实就是把读的位置移动最前面
        attachment.flip();  
        // 读取数据

        System.out.println("----------收到请求---------");
    }

    @Override
    public void failed(Throwable exc, ByteBuffer attachment) {

    }
}
